package com.wdf.dota;

import java.io.InputStream;

import com.wdf.bean.Info;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.text.Html;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;

public class HeroJiadianActivity extends Activity {


	

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.hero_jiadian);

		try {
		Bundle bundle = this.getIntent().getExtras();
		String heroname =	bundle.getString("heroname");

            Info info =new Info();
  
            String[] jiadian= info.getClass().getField(heroname).get(info).toString().split("-");
          
            
            for(int i= 0;i< jiadian.length; i++){
            	ImageView  jiadianmap = (ImageView ) findViewById(getResources().getIdentifier("jiadian"+(i+1), "id", "com.wdf.dota"));
            	String jiadianpath = "";
            	if("0".equals(jiadian[i])){
            		jiadianpath = "dota/"+ "skill.png";
            		jiadianmap.setOnClickListener(new OnClickListener(){
						@Override
						public void onClick(View v) {
							final MyDialog dialog = new MyDialog(HeroJiadianActivity.this, R.style.MyDialog);
							//dialog.setProperty(400, 500);
						     dialog.setContentView(R.layout.dialog);
						     dialog.setTitle("");
						     dialog.setContent(Html.fromHtml("每黄点加2点全属性。"));
								dialog. setPositiveButton("  ", new android.view.View.OnClickListener() {
									public void onClick(View v) {
										dialog.dismiss();
									}
								    });
						     dialog.show();
						}
            			
            		});
            	}else{
            		jiadianpath = "dota/"+heroname+ "_skill"+jiadian[i]+".png";
            		final String skill = bundle.getString("skill"+jiadian[i]);
            		if(skill != null){
            		jiadianmap.setOnClickListener(new OnClickListener(){
						@Override
						public void onClick(View v) {
							final MyDialog dialog = new MyDialog(HeroJiadianActivity.this, R.style.MyDialog);
							//dialog.setProperty(400, 600);
						     dialog.setContentView(R.layout.dialog);
						     dialog.setTitle("");
						     dialog.setContent(Html.fromHtml(skill));
								dialog. setPositiveButton("  ", new android.view.View.OnClickListener() {
									public void onClick(View v) {
										dialog.dismiss();
									}
								    });
						     dialog.show();
						}
            			
            		}); }
            	}
            	InputStream fis = getAssets().open( jiadianpath);
                Bitmap bm = BitmapFactory.decodeStream(fis);
                jiadianmap.setImageBitmap(bm);
            }

		} catch (Exception e) {
			e.printStackTrace();
		}
		
		
	}
}
